package com.sgcc.zipkinservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.logging.Level;
import java.util.logging.Logger;
/**
 * @Author: LiMengshuai
 * @CreateTime: 2019-08-02 15:22
 * @Description: ${Description}
 */
@SpringBootApplication
@RestController
public class ZipkinServiceBApplication {
    public static void main(String[] args) {
        SpringApplication.run(ZipkinServiceBApplication.class, args);
    }

    private static final Logger LOG = Logger.getLogger(ZipkinServiceBApplication.class.getName());



    @RequestMapping("/hi")
    public String callHome(){
        LOG.log(Level.INFO, "calling trace service-B  ");
        return restTemplate.getForObject("http://localhost:8888/miya", String.class);
    }
    @RequestMapping("/info")
    public String infob(){
        LOG.log(Level.INFO, "calling trace service-A ");

        return "i'm service-B";

    }

    @RequestMapping("/miya")
    public String info(){
        LOG.log(Level.INFO, "info is being called");
        return restTemplate.getForObject("http://localhost:8888/info",String.class);
    }

    @Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }


}
